import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate'
const store = createStore({
    state: {
        menut: [
            {
                name: "首页",
                path: "/console/home",
                children: []
            },
            {
                name: "存证管理",
                path: "/console/existing",
                children: []
            }, {
                name: "取证管理",
                path: "/console/obtain",
                children: []
            },
            {
                name: "充值及订单",
                path: "/console/topup",
                children: [
                    {
                        name: "订单管理",
                        path: "/console/topup/order"
                    },
                    {
                        name: "购买服务",
                        path: "/console/topup/shopp"
                    }
                ]
            }, {
                name: "账户管理",
                path: "/console/account",
                children: []
            },
            {
                name: "开放平台",
                path: "/console/platform",
                children: []
            }
        ],
        route: {
            name: "首页",
            path: "/console/home",
            children: []
        },
        tag: {
            token: "",
            userInfo: ""
        },
        userInfo: {
            id: ''
        },
        order: {  //订单信息

        },
        user: {  //用户信息

        }
    },
    getters: {
        menus(state) {
            return state.menut
        },
        pathname(state) {
            return state.route
        },
    },
    mutations: {
        setrouter(state, data) {
            state.route.path = data.path;
            state.route.name = data.name;
            state.route.children = data.children;
        },
        setTag(state, data) {
            state.tag.token = data.token
            state.tag.userInfo = data.user
        },
        setUserInfo(state, data) {
            state.userInfo.id = data.id
        },
        setOrder(state, data) {
            state.order = data
        },
        setUser(state, data) {
            state.user = data
        }
    },
    actions: {
    },
    modules: {
    },
    plugins: [
        // veux持久化配置
        createPersistedState({
            key: 'pcdata',
            paths: ['tag', 'route', 'userInfo', 'order', 'user']
        })
    ]
})
export default store

